unit main_window;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Regions;

type
  TForm1 = class(TForm)
    ComboBox1: TComboBox;
    ComboBox2: TComboBox;
    Edit1: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Button1: TButton;
    OpenDialog1: TOpenDialog;
    procedure Button1Click(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);
  private
    { Private declarations }
    Regions : Tregions;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation


{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
 stringstr : TStringStream;
 filestr : TFileStream;
 Size:   LongInt;
 Buffer: PChar;
 i : integer;
 List : TStringList;
begin

 if OpenDialog1.Execute then
 begin
  Edit1.Text:=OpenDialog1.FileName;
 { filestr := TFileStream.Create(Edit1.Text,fmOpenRead);
  stringstr := TStringStream.Create('');
  Size := filestr.Size;
  GetMem(Buffer, Size);

  filestr.Read(Buffer[0], Size);

  stringstr.Write(Buffer[0], Size);   }

  //ShowMessage(IntToStr(Length(Utf8ToAnsi(stringstr.DataString))));

  List := TStringList.Create;
  List.LoadFromFile(Edit1.Text);
//  Regions:=TRegions.Create(Edit1.Text,1);

  Regions:=TRegions.Create(Utf8ToAnsi(List.Strings[0]),0);

  Regions.GetRegions(ComboBox1.Items);

  List.Free;




  {FreeMem(Buffer);
  filestr.Free;  }
  end;
end;

procedure TForm1.ComboBox1Change(Sender: TObject);
begin
 Regions.GetCities(ComboBox1.Items.Strings[ComboBox1.ItemIndex],ComboBox2.Items);
end;

end.
